
#ifndef GIP_IMAGE_H
#define GIP_IMAGE_H 1

/* GipImage is a 32-bit color image (R+G+B+Alpha) */
/* alpha: 0=opaque, 255=transparent */

typedef struct _GipImage {
  unsigned char *data;
  int *tbrow;
  int width, height;
} GipImage;

/* creation */
GipImage *gip_image_new(int width, int height);
GipImage *gip_image_read_P6(char *filename);

/* Saving */
void gip_image_save_P6(char *filename);

/* destruction */
void      gip_image_destroy(GipImage *img);

/* single pixel operations */
void      gip_image_draw_point(GipImage *img, int x, int y,
			       unsigned char R, 
			       unsigned char B, 
			       unsigned char G);

void      gip_image_draw_point_alpha(GipImage *img, int x, int y,
				     unsigned char R, 
				     unsigned char B, 
				     unsigned char G,
				     int alpha);

int       gip_image_get(GipImage *img, int x,int y);

/* basic drawing operations */
void      gip_image_clear(GipImage *img, int color);

void      gip_image_rect(GipImage *img, int fill, int x,int y,
			 int w,int h,int color);

void      gip_image_draw_line(GipImage *img, int x1,int y1,
			      int x2,int y2, int color);

/* bit block operations */

/* bit block transfer, copies src to dest without reading dest,
   transparent regions in src become transparent in dest */
void      gip_image_bitblt(GipImage *dest, GipImage *src,
			   int x, int y, int w, int h);

/* bit block merge, pastes src over dest as an overlay, using
   the alpha channels for the merging */
void      gip_image_bitblm(GipImage *dest, GipImage *src,
			   int x, int y, int w, int h);

/* transforms */

GipImage *gip_image_copy(GipImage *src);
GipImage *gip_image_scale(GipImage *src, float factor);
GipImage *gip_image_rotate(GipImage *src, float degrees);

// TODO: brightness/contrast corrections

#endif
